
## Figure A.2.
## Annual number of articles about the headscarf

# Setup -------------------------------------------------------------------

# set working directory
setwd("")

# load packages
packs <- c("foreign", "data.table", "ggplot2", "tidyverse", "stringr", "stringi", "haven", 
           "readxl", "lubridate", "stats", "ggthemes", "plyr", "RColorBrewer", "scales")
lapply(packs, require, character.only = TRUE)

# read dataset of articles about headscarf
dt.xl <- read.csv(file="news_articles.csv")
dt.xl <- data.table(dt.xl)

# set location to save graphs
graphpath <- ""


# Creating Summary Datasets -------------------------------------------------------

## Limit dataset to articles from Le Monde 
lemonde <- dt.xl[source=="Le Monde",]

## Create count of Le Monde articles by year
annual_dt_lm <- plyr::ddply(.data=lemonde, .(date_year), summarise, 
                            n_articles = length(date_year))



# Plot Trends over Time -------------------------------------------------------

jpeg(filename = paste(as.character(graphpath), "/annual-news-plot-lemonde.jpg", sep=""), width=1200, height=700,type="quartz", res=130)
ggplot(data=annual_dt_lm, aes(x=date_year, y=n_articles)) + 
  geom_line() + 
  labs(x = "Year", y = "Number of Articles about Headscarf") + 
  theme(axis.text=element_text(size=12), axis.title=element_text(size=16)) + 
  scale_x_continuous(breaks=seq(1990, 2018, 2), limits=c(1990, 2019)) + 
  theme_few() + 
  theme(legend.position = "bottom")
dev.off()


